package com.ifinc.common.example;

import com.ifinc.common.exception.ValidException;
import com.ifinc.common.web.controller.ForwardAction;
import com.ifinc.common.web.controller.SessionMap;

import java.util.HashMap;
import java.util.Map;


public class UserController extends ForwardAction {


    public void validate(Map<String, String> header, Map<String, String> repParam, SessionMap<String, Object> sessionMap) {
        getLogger().info("hello");

        Map tipMap = new HashMap();
        String inputStr = "user/mesg";
        String username = repParam.get("username");
        if ("123".equals(username)) {
            tipMap.put("mesg", "username is not be 123");
            throw new ValidException("", "00040013", "", tipMap, inputStr);
        }

    }

    public String execute(Map<String, String> header, Map<String, String> reqParam
            , SessionMap<String, Object> sessionMap
            ,Map<String,Object> resultMap) {
        resultMap.put("username", "luotao1234");
        return "user/index.jsp";
    }


    public String exception(Map<String, String> reqParam, Map tipMap, SessionMap<String, Object> sessionMap, Exception e) {
        return null;
    }
}
